/******************************************************************************
COPYRIGHT    :
Project          : 
Source File Name : hwa_inputs_cfg.h
Group            : SoftWare Team
Author           : 
Date First Issued: 
********************************Documentation**********************************
Purpose -  This file contain all pre build configurable parameters as well as 
macro defines. 
********************************RevisionHistory********************************
_______________________________________________________________________________
Date : MM/DD/YY    Release        Changes Description                  Author
Date :                                                                 YONG.DING
   
******************************************************************************/

#ifndef hwa_inputs_Cfg_h
#define hwa_inputs_Cfg_h

/* #include */
#include "system.h"
/* #define */
//#define SAMPLING_R1          150 
//#define SAMPLING_R2          56  
//#define VBAT_13_5V           177
//#define VBATDELTA            7//0.7V

//#define VBAT_VALUE(x)        (UINT8)(((x*10 -VBATDELTA )*SAMPLING_R2*(UINT32)51)/((SAMPLING_R1+SAMPLING_R2)*(UINT16)10))//255/5V=51
#define VBAT_18V        (UINT8)78//VBAT_VALUE(18)//the AD value of +30 //
//#define VBAT_17_8V      						 //VBAT_VALUE(17.8)
#define VBAT_17_5V      (UINT8)75//VBAT_VALUE(17.5)  
#define VBAT_17V        (UINT8)73//VBAT_VALUE(17)                    
#define VBAT_16_5V      (UINT8)71//VBAT_VALUE(16.5)  
#define VBAT_16V        (UINT8)69//VBAT_VALUE(16)    
#define VBAT_15_5V      (UINT8)66//VBAT_VALUE(15.5)  
#define VBAT_15V        (UINT8)64//VBAT_VALUE(15)                    
#define VBAT_14_5V      (UINT8)62//VBAT_VALUE(14.5)   
#define VBAT_14V        (UINT8)58//VBAT_VALUE(14)    
#define VBAT_13_5V      (UINT8)56//VBAT_VALUE(13.5)                    
#define VBAT_13V        (UINT8)54//VBAT_VALUE(13)                   
#define VBAT_12_5V      (UINT8)52//VBAT_VALUE(12.5)  
#define VBAT_12V        (UINT8)49//VBAT_VALUE(12)     
#define VBAT_11_5V      (UINT8)46//VBAT_VALUE(11.5)  
#define VBAT_11V        (UINT8)44//VBAT_VALUE(11)     
#define VBAT_10_5V      (UINT8)42//VBAT_VALUE(10.5)   
#define VBAT_10V        (UINT8)40//VBAT_VALUE(10)         
#define VBAT_9_5V       (UINT8)36//VBAT_VALUE(9.5)     
#define VBAT_9V         (UINT8)34//VBAT_VALUE(9)//115 
#define VBAT_8_5V       (UINT8)31//VBAT_VALUE(8.5)    
#define VBAT_8V         (UINT8)28//VBAT_VALUE(8)   
#define VBAT_7_5V		(UINT8)25//VBAT_VALUE(7.5)        
#define VBAT_7V		    (UINT8)22//VBAT_VALUE(7)       
#define VBAT_6_5V       (UINT8)19//VBAT_VALUE(6.5)    // /* add to monitor the V_BAT to decide if we should stop/resume sending CAN msg per Chery's request */
#define VBAT_6V         (UINT8)16//VBAT_VALUE(6)      // /* add to monitor the V_BAT to decide if we should stop/resume sending CAN msg per Chery's request */
//#define VBAT_5_9V       (UINT8)43//VBAT_VALUE(5.9)   


#define GPI_DEB_CYCLES        3   /* debounce_time = DEB_CYCLES x cycle_time */
#define AD_DEB_CYCLES         3
#define DEB_LONGCYCLE	10

#define MCU		(UINT8)0x00
#define MUX		(UINT8)0x01

//input port mask	
#define NO_INPUT		(0xFF)
#define SI_NO_INPUT		NO_INPUT


#define CH0       0
#define CH1       1
#define CH2       2
#define CH3       3
#define CH4       4
#define CH5       5
#define CH6       6
#define CH7       7
#define CH8       8
#define CH9       9
#define CH10      10
#define CH11      11
#define CH12      12


#define   ADR_PORT_NULL     ((UINT16)0)
//#define   ADR_PORT_A		((UINT16)&PORTA)
//#define   ADR_PORT_B		((UINT16)&PORTB)
//#define   ADR_PORT_C		((UINT16)&PORTC)
//#define   ADR_PORT_D		((UINT16)&PORTD)
#define   ADR_PORT_T		((UINT16)&PTIT)
#define   ADR_PORT_S		((UINT16)&PTIS)
#define   ADR_PORT_M		((UINT16)&PTIM)
#define   ADR_PORT_P		((UINT16)&PTIP)
#define   ADR_PORT_J        ((UINT16)&PTIJ)
#define   ADR_PORT_AD0		((UINT16)&PTI0AD)
#define   ADR_PORT_AD1		((UINT16)&PTI1AD)



//input active matix 
#define H 	(0x00)
#define L	(0x01)

/* typedef */ 
typedef struct _DIN_GPI_RESULT_STRUCT {
    UINT8  debouncedState;
    UINT8  Hdebounced_cnt;
    UINT8  Ldebounced_cnt;
}DIN_GPI_RESULT_STRUCT;
typedef struct _DIN_CONFIG_STRUCT
{
    UINT8	  u8_inputIndex;
    UINT8  	u8_portName;
    UINT16 	u16_address;
    UINT8 	u8_pinIndex;
    UINT8 	u8_activeLevel;   
}DIN_CONFIG_STRUCT;  

typedef struct _AIN_RESULT_STRUCT
{
	UINT8   channel;
	UINT16 	debouncedADValue;
	UINT16 	tempADValueCur;
	UINT16 	tempADValueLast;
	UINT8 	debounced_cnt;
   
}AIN_RESULT_STRUCT;

typedef enum
{
	MUX1 = 0,
	NUM_OF_MUX
} MUX_ENUM;  

typedef enum 
{
//	DIN_PORT_A = 0,
//	DIN_PORT_B,	
//	DIN_PORT_C,	
	DIN_PORT_T,
	DIN_PORT_P,
	DIN_PORT_J,
	DIN_PORT_AD1,
	DIN_PORT_AD0,

	NUM_OF_DIN,
	
	/*******************/
}DIN_ENUM;


typedef enum 
{
	SI_PP0_IN,
	SI_PP1_IN,
	SI_PP3_IN,
	SI_PT0_IN,
	SI_PT1_IN,
	SI_PT2_IN,
   
	NUM_OF_INPUTS,	
}INPUTS_ENUM; 


typedef enum 
{
    SA_PAD1_AN,//
    SA_PAD2_AN,//
	SA_PAD8_AN,//
	SA_PAD9_AN,//
	SA_PAD10_AN,//
	NUM_OF_AN,
}AIN_ENUM;  



//extern TEMPER_SENSOR TEMPER_SENSOR_ARR[];
//extern const AIN_CONFIG_STRUCT c_s_AIN_CONFIG[];
extern AIN_RESULT_STRUCT      AIN_RESULT[NUM_OF_AN];

/*****************************************************************************/
#endif
/*************************end of hwa_inputs_cfg.h********************************/

/******************************************************************************
 Revision Notes:

For each change to this file, be sure to record:
1. Who made the change and when the change was made.
2. Why the change was made and the intended result.

  Date     By     Reason For Change
mm/dd/yy  XXX     -----------------

                
******************************************************************************/

